/**
 * 
 */
package edu.simplemqom.objects;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

import edu.simplemqom.Message;

/**
 * @author Adam
 *
 */
public class ChannelLogger implements ChannelLoggerInterface {

	private String fileName;
	private String name;
	public ChannelLogger(String channelName) {
		String name = this.getClass().getName();
		this.fileName = new String(channelName + "_" + name + "_" + "log.txt");
		this.name = new String(channelName + "_" + name);
		
	}
	
	public String getName() {
		return name;
	}
	/* (non-Javadoc)
	 * @see edu.simplemqom.objects.ChannelLoggerInterface#addToLogList(java.lang.String)
	 */
	@Override
	public void log(Message log) {
		try {
			PrintWriter writer = new PrintWriter(new FileOutputStream(new File(fileName), true));
			writer.println(log);
			writer.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	@Override
	public void close() {
		
	}

}
